home *** CD-ROM | disk | FTP | other *** search
/ Playboy Electronic Datebook / Playboy Electronic Datebook - Disk 1.img / VERSION.MS_ / VERSION.MS
Text File  |  1993-10-22  |  12KB  |  335 lines

  1. '$IFDEF VERSION
  2.  
  3.  
  4.  
  5. '**
  6. '** Purpose:
  7. '**     Version checking...
  8. '**
  9. '**
  10. '** Arguments:
  11. '**     szDest$ - Destination of the files to be installed
  12. '**     szIni$ - Ini file which contains the version info.
  13. '**     szIniSect$ - Section of the ini file that contains the verion info.
  14. '** Returns:
  15. '**
  16. '*************************************************************************
  17. FUNCTION Version (szDest$, szIni$, szIniSect$) STATIC AS INTEGER
  18.  
  19.         DIM rVerInfo AS VERSION
  20.  
  21.         Cursor% = ShowWaitCursor()
  22.  
  23.         VER_FILELIST$ = "ThemeFiles"
  24.         nItems% = MakeListIniKeys(szIni$, szIniSect$)
  25.  
  26.         FOR i% = 1 TO nItems% STEP 1
  27.             rVerInfo.FileName = RTRIM$(GetListItem(VER_FILELIST$,i%))
  28.             szVerList$ = GetIniKeyString(szIni$, szIniSect$,RTRIM$(rVerInfo.FileName))
  29.             rVerInfo.InitVer = GetNthFieldFromIniString(szVerList$, INIT_VER_POS)
  30.             rVerInfo.CurVer  = GetNthFieldFromIniString(szVerList$, CUR_VER_POS)
  31.  
  32.             iItem% = PAR_FILE_POS ''position of the first parent filename
  33.  
  34.             WHILE (TRUE)
  35.                 szParFile$ = GetNthFieldFromIniString(szVerList$, iItem%)
  36.  
  37.                 IF LEN(szParFile$) = 0 THEN
  38.                     EXIT WHILE
  39.                 ELSE
  40.                     iItem% = iItem% + 1
  41.                     IF DoesFileExist(MakePath(szDest$,szParFile$),femRead) THEN
  42.  
  43.                         szParInit$ = GetFileInitVer(MakePath(szDest$,szParFile$))
  44.                         szParCur$  = GetFileCurVer(MakePath(szDest$,szParFile$))
  45.  
  46.                         IF (LEN(szParInit$) <> 0) OR (LEN(szParCur$) <> 0) THEN
  47.                             IF INSTR(rVerInfo.FileName, szParFile$) > 0 THEN
  48.                                 iResult% = TestDupe(rVerInfo.InitVer, rVerInfo.CurVer, szParInit$,szParCur$)
  49.                             ELSE
  50.                                 iResult% = TestRange(rVerInfo.InitVer, rVerInfo.CurVer, szParInit$,szParCur$)
  51.                             END IF
  52.                             IF (iResult% = -1) THEN
  53.  
  54.                                 iRC% = DoMsgBox(MSG_THE_FILE + RTRIM$(rVerInfo.FileName) + VERSION_APPFILE_NC + MakePath(szDest$,szParFile$) + VERSION_APPFILE_OLD, VERSION_CAPTION, MB_ICONHAND+MB_TASKMODAL+MB_OK)
  55.  
  56.                                 AddListItem BadFileList$, RTRIM$(rVerInfo.FileName)
  57.                                 EXIT WHILE
  58.  
  59.                             ELSEIF (iResult% = 1) THEN
  60.                                 '' Do we notify user that the install file is newer than the parent???
  61.                             END IF
  62.                         ELSE
  63.                             EXIT WHILE  ''something went wrong getting the parent versions
  64.                         END IF
  65.                     END IF
  66.                 END IF
  67.             WEND
  68.  
  69.         NEXT i%
  70.  
  71.     VERSION = 0
  72.     IF GetListLength(VER_FILELIST$) <> 0 THEN
  73.         RemoveSymbol VER_FILELIST$
  74.     END IF
  75.  
  76.     RestoreCursor Cursor%
  77.  
  78. END FUNCTION
  79.  
  80.  
  81. '**
  82. '** Purpose:
  83. '**     Content Version checking...
  84. '**     For each theme pack listed in the Amaze.ini, the theme.dll will be check as a child
  85. '**     against the files listed in the szIniSect$ of the szIni$ file.
  86. '**     If the theme is older or newer that the files being installed, a message will pop up.
  87. '**
  88. '** Arguments:
  89. '**     szDest$ - Destination of the files to be installed
  90. '**     szIni$ - Ini file which contains the version info.
  91. '**     szIniSect$ - Section of the ini file that contains the verion info for the content.
  92. '** Returns:
  93. '**
  94. '*************************************************************************
  95. FUNCTION ContentVersion (szDest$, szIni$, szIniSect$) STATIC AS INTEGER
  96.  
  97.         DIM rVerInfo AS VERSION
  98.         bBadTheme% = 0
  99.  
  100.         Cursor% = ShowWaitCursor()
  101.  
  102.         VER_FILELIST$ = "ThemeFiles"
  103.         nItems% = MakeListIniKeys(szIni$, szIniSect$)
  104.         FOR t% = 1 TO iMaxNumTP% STEP 1
  105.  
  106.             IF DoesIniKeyExist(ini$, INI_SEC_THEME_PACKS, INI_KEY_TP+LTRIM$(STR$(t%)) ) = 1 THEN
  107.                 szTheme$ = GetIniKeyString( ini$, INI_SEC_THEME_PACKS, INI_KEY_TP+LTRIM$(STR$(t%)) )
  108.                 IF (bDDDInData%) THEN
  109.                     szDDDFile$ = INI_KEY_DATA
  110.                 ELSE
  111.                     szDDDFile$ = INI_KEY_MASTER
  112.                 END IF
  113.                 IF DoesIniKeyExist(ini$, szTheme$, szDDDFile$) THEN
  114.                     szThemeDllPath$ = GetIniKeyString(ini$, szTheme$, szDDDFile$)
  115.                     IF DoesFileExist(szThemeDllPath$, femRead) THEN
  116.                         rVerInfo.FileName = szThemeDllPath$
  117.                         szStrBuf$ = STRING$(20,32)
  118.                         iRC% = ReadStrResource(RTRIM$(rVerInfo.FileName), IDS_THEMEPACK_DLL_VERSION, szStrBuf$, LEN(szStrBuf$))
  119.  
  120.                         rVerInfo.InitVer = szStrBuf$
  121.                         rVerInfo.CurVer = szStrBuf$
  122.  
  123.                         FOR i% = 1 TO nItems% STEP 1
  124.                             szFileName$ = RTRIM$(GetListItem(VER_FILELIST$,i%))
  125.                             szVerList$ = GetIniKeyString(szIni$, szIniSect$,RTRIM$(szFileName))
  126.                             szInitVer$ = GetNthFieldFromIniString(szVerList$, INIT_VER_POS)
  127.                             szCurVer$  = GetNthFieldFromIniString(szVerList$, CUR_VER_POS)
  128.  
  129.                             IF (DoesFileExist(MakePath(szDest$,szFileName$),femRead) = 1) THEN
  130.  
  131.                                 IF (LEN(szInitVer$) <> 0) OR (LEN(szCurVer$) <> 0) THEN
  132.                                     iResult% = TestRange(rVerInfo.InitVer, rVerInfo.CurVer, szInitVer$, szCurVer$)
  133.                                     IF (iResult% <> 0) THEN
  134.                                         iRC% = DoMsgBox(szTheme$ + VERSION_BAD_CONTENT, VERSION_CAPTION, MB_ICONHAND+MB_TASKMODAL+MB_OK)
  135.                                         bBadTheme% = 1
  136.                                         EXIT FOR
  137.                                     END IF
  138.                                 END IF
  139.                             END IF
  140.                         NEXT i%
  141.  
  142.                     END IF
  143.                 END IF
  144.             END IF
  145.  
  146.         NEXT t%
  147.  
  148.         ContentVersion = bBadTheme%
  149.  
  150.         IF GetListLength(VER_FILELIST$) <> 0 THEN
  151.             RemoveSymbol VER_FILELIST$
  152.         END IF
  153.  
  154.         RestoreCursor Cursor%
  155.  
  156. END FUNCTION
  157.  
  158.  
  159.  
  160. '**
  161. '** GetFileInitVer()
  162. '**
  163. '** Purpose:
  164. '**
  165. '** Arguments:
  166. '**
  167. '** Returns:
  168. '**
  169. '*************************************************************************
  170.  
  171. FUNCTION GetFileInitVer(szFile$) STATIC AS STRING
  172.  
  173.     DIM szStrBuf$
  174.     szStrBuf$ = STRING$(20,32)
  175.  
  176.     iRC% = ReadStrResource(szFile$, IDS_INITIAL_VERSION, szStrBuf$, LEN(szStrBuf$))
  177.  
  178.     GetFileInitVer = szStrBuf$
  179.  
  180. END FUNCTION
  181.  
  182.  
  183. '**
  184. '** GetFileCurVer()
  185. '**
  186. '** Purpose:
  187. '**
  188. '** Arguments:
  189. '**
  190. '** Returns:
  191. '**
  192. '*************************************************************************
  193.  
  194. FUNCTION GetFileCurVer(szFile$) STATIC AS STRING
  195.  
  196.     DIM szStrBuf$
  197.     szStrBuf$ = STRING$(20,32)
  198.  
  199.     iRC% = ReadStrResource(szFile$, IDS_CURRENT_VERSION, szStrBuf$, LEN(szStrBuf$))
  200.  
  201.     GetFileCurVer = szStrBuf$
  202.  
  203. END FUNCTION
  204.  
  205.  
  206. '**
  207. '** TestRange()
  208. '**
  209. '**     Purpose:
  210. '**         Compares initial and current version strings of a file
  211. '**         to init and cur verions of its parent file.
  212. '**
  213. '**     Arguments:
  214. '**         Init and Cur version strings of child and parent
  215. '**
  216. '**     Returns:
  217. '**         Integer:
  218. '**             -1 if existing parent file is newer
  219. '**              0 if file is in range
  220. '**              1 if file is newer than parent file
  221. '**
  222. '*************************************************************************
  223.  
  224. FUNCTION TestRange(szChildInitVer AS STRING, szChildCurVer AS STRING,szParInitVer AS STRING,szParCurVer AS STRING) STATIC AS INTEGER
  225.     ''PRINT "In TestRange..."
  226.     ''PRINT "szChildInitVer = " + szChildInitVer
  227.     ''PRINT "szChildCurVer = " + szChildCurVer
  228.     ''PRINT "szParInitVer = " + szParInitVer
  229.     ''PRINT "szParCurVer = " + szParCurVer
  230.     iChildInitMaj% = VAL(MID$(szChildInitVer,1,2))
  231.     iChildCurMaj%  = VAL(MID$(szChildCurVer,1,2))
  232.     iChildInitMin% = VAL(MID$(szChildInitVer,4,2))
  233.     iChildCurMin%  = VAL(MID$(szChildCurVer,4,2))
  234.     iParInitMaj%   = VAL(MID$(szParInitVer,1,2))
  235.     iParCurMaj%    = VAL(MID$(szParCurVer,1,2))
  236.     iParInitMin%   = VAL(MID$(szParInitVer,4,2))
  237.     iParCurMin%    = VAL(MID$(szParCurVer,4,2))
  238. '$IFDEF DEBUG
  239.     iChildInitBeta% = 0 ''VAL(MID$(szChildInitVer,7,3))
  240.     iChildCurBeta%  = VAL(MID$(szChildCurVer,7,3))
  241.     iParInitBeta%   = 0 ''VAL(MID$(szParInitVer,7,3))
  242.     iParCurBeta%    = VAL(MID$(szParCurVer,7,3))
  243. '$ENDIF
  244.  
  245.     IF iChildInitMaj% > iParCurMaj% THEN
  246.         TestRange = 1
  247.         ''PRINT "iChildInitMaj%="+STR$(iChildInitMaj%)+" > iParCurMaj%="+STR$(iParCurMaj%)
  248.         GOTO END_TESTRANGE
  249.     ELSEIF iChildCurMaj% < iParInitMaj% THEN
  250.         TestRange = -1
  251.         ''PRINT "iChildCurMaj% < iParInitMaj%"
  252.         GOTO END_TESTRANGE
  253.     ELSE  ''child in range of parent
  254.         IF iChildInitMin% > iParCurMin% THEN
  255.             TestRange = 1
  256.             ''PRINT "iChildInitMin% > iParCurMin%"
  257.             GOTO END_TESTRANGE
  258.         ELSEIF iChildCurMin% < iParInitMin% THEN
  259.             TestRange = -1
  260.             ''PRINT "iChildCurMin% < iParInitMin%"
  261.             GOTO END_TESTRANGE
  262. '$IFDEF DEBUG
  263.         ELSE  ''child in range of parent
  264.             IF iChildInitBeta% > iParCurBeta% THEN
  265.                 TestRange = 1
  266.                 ''PRINT "iChildInitBeta% > iParCurBeta%"
  267.                 GOTO END_TESTRANGE
  268.             ELSEIF iChildCurBeta% < iParInitBeta% THEN
  269.                 TestRange = -1
  270.                 ''PRINT "iChildCurBeta% < iParInitBeta%"
  271.                 GOTO END_TESTRANGE
  272.  
  273.             ELSE
  274.                 TestRange = 0
  275.                 GOTO END_TESTRANGE
  276.             END IF  ''Beta
  277. '$ENDIF
  278.         END IF  ''Minor
  279.         TestRange = 0
  280.     END IF  ''major
  281.     ''PRINT "TestRange = 0"
  282.     TestRange = 0
  283. END_TESTRANGE:
  284. END FUNCTION
  285.  
  286.  
  287. '**
  288. '** TestDupe()
  289. '**
  290. '**     Purpose:  Avoid overwriting a newer version of the same file
  291. '**         Compares initial and current version strings of a file
  292. '**         to init and cur verions of its duplicate file.
  293. '**
  294. '**     Arguments:
  295. '**         Init and Cur version strings of child and parent should be same file
  296. '**
  297. '**     Returns:
  298. '**         Integer:
  299. '**             -1 if existing parent file is newer
  300. '**              0 if file is in range
  301. '**              1 if new file is newer than existing file
  302. '**
  303. '*************************************************************************
  304.  
  305. FUNCTION TestDupe(szChildInitVer AS STRING, szChildCurVer AS STRING,szParInitVer AS STRING,szParCurVer AS STRING) STATIC AS INTEGER
  306.  
  307.     iChildInitMaj% = VAL(MID$(szChildInitVer,1,2))
  308.     iChildCurMaj%  = VAL(MID$(szChildCurVer,1,2))
  309.     iChildInitMin% = VAL(MID$(szChildInitVer,4,2))
  310.     iChildCurMin%  = VAL(MID$(szChildCurVer,4,2))
  311.     iParInitMaj%   = VAL(MID$(szParInitVer,1,2))
  312.     iParCurMaj%    = VAL(MID$(szParCurVer,1,2))
  313.     iParInitMin%   = VAL(MID$(szParInitVer,4,2))
  314.     iParCurMin%    = VAL(MID$(szParCurVer,4,2))
  315.  
  316.     IF iChildCurMaj% < iParCurMaj% THEN
  317.         TestDupe = -1
  318.         ''PRINT "iChildInitMaj%="+STR$(iChildInitMaj%)+" > iParCurMaj%="+STR$(iParCurMaj%)
  319.         GOTO END_TESTDUPE
  320.     ELSEIF iChildCurMaj% = iParCurMaj%  THEN  ''child in range of parent
  321.         IF iChildCurMin% < iParCurMin% THEN
  322.             TestDupe = -1
  323.             ''PRINT "iChildInitMin% > iParCurMin%"
  324.             GOTO END_TESTDUPE
  325.         END IF  ''Minor
  326.         TestDupe = 0
  327.     END IF  ''major
  328.     TestDupe = 0
  329. END_TESTDUPE:
  330. END FUNCTION
  331.  
  332. '$ENDIF   ''ifdef VERSION
  333.  
  334.  
  335.